#pragma once
#include <stdint.h>
#include <stdio.h>

#define offsetof(TYPE, MEMBER) ((size_t)&((TYPE *)0)->MEMBER)

#define container_of(ptr, type, member) ({                      \
    const typeof( ((type *)0)->member ) *__mptr = (ptr);    \
    (type *)( (char *)__mptr - offsetof(type,member) );})

#define list_for_each(node, list) \
            for(node = ((struct linked_list*)list)->head; \
                node != NULL; \
                node = node->next)

struct linked_node {
    struct linked_node* next;
};

struct linked_list {
    struct linked_node* head;
    uint32_t count;
};

int32_t list_push(struct linked_list* list, struct linked_node* node);